$(document).ready(function(){

    mui.init({
        pullRefresh: {
            container: '#pullrefresh',
            down: {
                callback: pulldownRefresh
            },
            up: {
                contentrefresh: '正在加载...',
                callback: pullupRefresh
            }
        }
    });

    mzpost({
        url:pub_recode,
        data:{},
        success:function(res){
            if(res.code == '2000'){
               var data = res.data;
            
               createList(data);
              
            }else{
                mui.toast(res.msg);
            }
        },
        error:function(err){
            mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
            mui.toast('获取记录错误');
        }
    })

})

function pulldownRefresh() {
    mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); 
}
function pullupRefresh() {
    mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
}

function createList(data){
    if(data.length == 0){
        mui.toast('没有记录');
        return;
    }
    $.each(data,function(i,item){

    $('<div id="'+item.orde_sn+'" class="mui-content">'+
        '<div class="mui-row mui-row-title">'+
            '<div class="mui-col-xs-4 cell">货号</div>'+
            '<div class="mui-col-xs-8 cell">'+item.gid+'</div>'+
        '</div>'+
        '<div class="mui-row">'+
            '<div class="mui-col-xs-4 cell">上架时间</div>'+
            '<div class="mui-col-xs-8 cell">'+formateDate(item.add_time)+'</div>'+
        '</div>'+
        '<div class="mui-row">'+
            '<div class="mui-col-xs-4 cell">商品名称</div>'+
            '<div class="mui-col-xs-8 cell">'+item.name+'</div>'+
        '</div>'+
        '<div class="mui-row">'+
            '<div class="mui-col-xs-4 cell">商品单价</div>'+
            '<div class="mui-col-xs-8 cell">'+item.money+'</div>'+
        '</div>'+
        '<div class="mui-row">'+
            '<div class="mui-col-xs-4 cell">上架数量</div>'+
            '<div class="mui-col-xs-8 cell">'+item.num+'</div>'+
        '</div>'+
    '</div>').appendTo('.mz-list-box');
    })
}
